<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <style>
    #box {
      display: flex;
    }
    #box1 {
      width: 200px;
      height: 200px;
      border: 2px solid #111;
      background-color: chocolate;
    }
  </style>
  <body>
    <button onclick="btn1()">红</button>
    <button onclick="btn2()">绿</button>
    <button onclick="btn3()">蓝</button>
    <button onclick="btn4()">紫</button>
    <button onclick="btn5()">橙</button>
    <div id="box1"></div>
  </body>
  <script>
    var div = document.getElementById("box1");
    var btn = document.getElementsByClassName("button");
    function btn1() {
      console.log(111);
      box1.style.backgroundColor = "red";
    }
    function btn2() {
      console.log(222);
      box1.style.backgroundColor = "chartreuse";
    }
    function btn3() {
      console.log(333);
      box1.style.backgroundColor = "aqua";
    }
    function btn4() {
      console.log(444);
      box1.style.backgroundColor = "blueviolet";
    }
    function btn5() {
      console.log(555);
      box1.style.backgroundColor = "chocolate";
    }
  </script>
</html>
